Skip to content

Load block hash history when starting from non-genesis block#310

Merged
LorenzSchueler merged 1 commit into
mainfrom
lorenz/fix-hash-history
Jul 8, 2026
Merged

Load block hash history when starting from non-genesis block#310
LorenzSchueler merged 1 commit into
mainfrom
lorenz/fix-hash-history

Conversation

@LorenzSchueler

Copy link
Copy Markdown
Collaborator

This PR loads the block hash history when starting from a non-genesis block (block 0). The block hash history is an in-memory buffer containing the last 256 block hashes. While replaying blocks it updates this buffer to stay up to date. When starting from some block >0, this history was previously empty (all zero hashes). This is incorrect can cause the replay to fail.
Now, the hashes are loaded from the parent hashes stored in the block db.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes replay correctness when starting from a non-genesis block by pre-populating the in-memory 256-block hash ring (blockHashHistory) from hashes stored in the block DB, so EVM BLOCKHASH lookups and parent-hash validation work during replays that begin mid-chain.

Changes:

  • Pass the block DB into state preparation so replay startup can seed historic block hashes when StartBlock > 0.
  • Add seedBlockHashHistory to load the last ~256 prior block hashes from the block DB (via each block’s ParentHash).
  • Add unit tests covering the seeding window logic and error propagation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
go/replay/replay.go Seeds blockHashHistory from the block DB when starting replay from a non-genesis block.
go/replay/replay_test.go Adds focused tests for seedBlockHashHistory behavior across boundary conditions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread go/replay/replay.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread go/replay/replay.go
Comment thread go/replay/replay.go
@LorenzSchueler
LorenzSchueler force-pushed the lorenz/fix-hash-history branch from e29d112 to b96d0b1 Compare July 8, 2026 13:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread go/replay/replay.go
@LorenzSchueler
LorenzSchueler merged commit 085acbb into main Jul 8, 2026
17 checks passed
@LorenzSchueler
LorenzSchueler deleted the lorenz/fix-hash-history branch July 8, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants